package com.diandian.backend.meituan.shangou.exchange.controller;

import com.diandian.backend.meituan.shangou.exchange.req.GetProductSkuInfoReq;
import com.diandian.backend.meituan.shangou.exchange.req.SkuStockUpdateOneReq;
import com.diandian.backend.meituan.shangou.exchange.service.BusinessSkuStockManageService;
import com.diandian.base.boot.starter.response.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品SKU管理
 */
@RestController
@RequestMapping("/business/product/sku")
public class BusinessProductSkuController {

    @Autowired
    private BusinessSkuStockManageService skuStockManageService;

    /**
     * 同步单个商品库存
     */
    @PostMapping("/skuStockUpdateOne")
    public BaseResult skuStockUpdateOne(@RequestHeader(value = "appKey") String appKey,
                                        @RequestHeader(value = "appSecret") String appSecret,
                                        @RequestHeader(value = "belong") String belong,
                                        @RequestBody SkuStockUpdateOneReq data) throws Exception {
        return new BaseResult(0, "success", skuStockManageService.skuStockUpdateOne(appKey, appSecret, belong, data));
    }

    /**
     * 查询商品sku库存信息
     */
    @PostMapping("/getProductSkuStockInfo")
    public BaseResult getProductSkuStockInfo(@RequestHeader(value = "appKey") String appKey,
                                        @RequestHeader(value = "appSecret") String appSecret,
                                        @RequestHeader(value = "belong") String belong,
                                        @RequestBody GetProductSkuInfoReq data) {
        return new BaseResult(0, "success", skuStockManageService.getProductSkuStockInfo(appKey, appSecret, belong, data));
    }
}
